<template>
    <div>
        <div class="box" style="height: 30px;"></div>
        <van-row>
            <van-col span="8">
                <div>
                    <van-sidebar v-model="active">
                        <van-sidebar-item v-for="item in categoriesApiData" :title="item.cat_name" />
                    </van-sidebar>
                </div>

            </van-col>
            <van-col span="16">
                <swiper :images="images" imgwidth="100%" imgheight="150px"/>
                <div v-for="item in categoriesApiData[active]?.children">
                    <h4>{{ item.cat_name }}</h4>
                    <router-link :column-num="3" :to="{ name: 'shop', params: { query: cat_name } }">
                        <van-grid>
                            <van-grid-item v-for="item in item.children" :icon="item.cat_icon" :text="item.cat_name" />
                        </van-grid>
                    </router-link>
                </div>
            </van-col>
        </van-row>

    </div>
</template>

<script setup>
import { categoriesApi } from '@/api/api'
import { ref } from 'vue'
//轮播图组件复用
import swiper from '@/components/swiper.vue'
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-5.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-6.jpeg',
];
const categoriesApiData = ref([])
categoriesApi().then((res) => {
    console.log('分类', res);
    categoriesApiData.value = res.data.message
})
const active = ref(0);


</script>

<style lang="scss" scoped></style>